/*
 * @Description: 文章列表 - item
 * @Date: 2020-09-09 14:12:30
 * @Author: 黄治恩
 */

import React, { Component } from 'react'
import { Image  } from 'antd';
import { Link } from 'react-router-dom'

// 点赞/评论
import Operation from '@/components/Operation/Home-operation'

import './style.scss'

interface Props_type {
  item:{id:number,like?:number},
  className:string
}

class EntryItem extends Component<Props_type>{

  state = {
    info:{...this.props.item,like:1}
  }

  /**
   * @description 跳转详情
   * @param {object} info 
   */
  onDetail(info:{id:number|string}){
    let path = `/article?id=${info.id}`
    window.open(path)
  }


  render() {
    let { info } = this.state
    return (
      <li className="sy-article-box" onClick={()=> this.onDetail(info)}>
        <div className="info-box">
          <div className="info-box__header">
            <div className="item name">哈哈哈</div>
            <div className="item time">time</div>
            <div className="item label">
              <Link to="/hot" target="_blank" className="tag">
                第一个
              </Link>
            </div>
          </div>
          <h2 className="info-box__title">
            <Link to={`/article?id=${info.id}`} target="_blank" onClick={(e)=>e.stopPropagation()}>我是标题</Link>
          </h2>
          {/* 点赞/评论 */}
          <Operation item={info} />
        </div>
        <Image className="user-pic" width={60} height={60} src="@/assets/img/user/user1.png" />
      </li>
    )
  }
}

export default EntryItem